<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="file" id="input">
<button id="button">点击</button>
<script src="../lib/baitu.min.js"></script>
<script>
    const ternaryRes = Baitu.Ternary.if(() => {
        return true;
    }, "1")
        .else("2")
        .if(() => {
            return true;
        }, "3").get();
    console.log(ternaryRes);

    const list = [{
        name: 'ASD',
        pattern: 'asd'
    }]

    class PatternPoolNew extends Baitu.PatternPollClass {
        fs = "1"
        cc = "12"
    }

    Baitu.setPatternPool(new PatternPoolNew());

    Baitu.PatternPool.add(list);
    console.log(Baitu.ValidateUtil.validate("cc", Baitu.PatternPool.cc))

    console.log(Baitu.ValidateUtil.validate("053188881234", Baitu.PatternPool.LANDLINE));


    console.log(Baitu.ValidateUtil.isEmail("123@qq.com"))
    console.log(Baitu.DesensitizedUtil.bankAccount("6221964588367633387"))
    const {DateTime} = Baitu;
    console.log(new DateTime())

    const date1 = new Date();
    const date2 = new Date("2023-05-16");
    console.log(Baitu.DateUtil.compare(date1, date2, Baitu.DateField.DAY));

    console.log(Baitu.ObjectUtil.isEmpty(["1"]))
    const button = document.querySelector("#button");

    function click(e) {
        console.log(e)
        console.log("1111")
    }

    button.addEventListener('click', Baitu.Debounce.with(click, 2000))


    const input = document.querySelector("#input");
    input.onchange = () => {
        const file = input.files[0];
        if (file) {
            try {
                Baitu.ImgUtil.cut(file, 300, 300, 500, 700, 0.5).then(res => {
                    console.log(res)
                    Baitu.FileUtil.downloadBlob(res.blob, res.name);
                })
                Baitu.ImgUtil.resize(file, 300, 300).then(res => {
                    console.log(res)
                    Baitu.FileUtil.downloadBlob(res.blob, res.name);
                })
                Baitu.FileUtil.isTypeMagic(file, "png").then(res => {
                    console.log(res)
                })
            } catch (error) {
                console.error('Error reading file:', error);
            }
        }
    };
</script>
</body>
</html>
